part of 'component.dart';

class ExpandedButton extends StatelessWidget {
  const ExpandedButton({
    Key? key,
    required this.text,
    this.textColor,
    this.fontSize,
    this.backgroundColor,
    this.height,
    this.borderradius,
    this.indent = 0,
    this.onPressed,
  }) : super(key: key);
  final String text;
  final Color? textColor;
  final double? fontSize;
  final Color? backgroundColor;
  final double? height;
  final double? indent;
  final BorderRadiusGeometry? borderradius;
  final VoidCallback? onPressed;
  @override
  Widget build(BuildContext context) {
    var _height = height ?? buttonHeight;
    return Row(
      children: [
        SizedBox(
          width: indent,
        ),
        Expanded(
            child: MaterialButton(
          onPressed: onPressed,
          height: _height,
          color: backgroundColor ?? ColorsUtil.green,
          disabledColor: backgroundColor ?? ColorsUtil.green,
          shape: RoundedRectangleBorder(
              borderRadius: borderradius ?? BorderRadius.circular(5)),
          child: Text(
            text,
            style: pfSCStyle(
                color: textColor ?? ColorsUtil.white,
                fontSize: fontSize ?? 18.sp),
          ),
        )),
        SizedBox(
          width: indent,
        ),
      ],
    );
  }
}

class IconTextButton extends StatelessWidget {
  const IconTextButton({
    Key? key,
    required this.icon,
    required this.text,
    this.spacing,
    this.padding,
    this.margin,
    this.decoration,
    this.alignment = Alignment.center,
  }) : super(key: key);
  final Widget icon;
  final Widget text;
  final double? spacing;
  final EdgeInsets? padding;
  final EdgeInsets? margin;
  final BoxDecoration? decoration;
  final Alignment alignment;
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: padding,
      margin: margin,
      decoration: decoration,
      alignment: alignment,
      child: Row(
        children: [
          icon,
          SizedBox(
            width: spacing,
          ),
          text,
        ],
      ),
    );
  }
}

class BorderButton extends StatelessWidget {
  const BorderButton({
    Key? key,
    required this.title,
    required this.color,
    this.width,
    this.height,
    this.fontSize = 15,
    this.onTap,
  }) : super(key: key);
  final String title;
  final Color color;
  final double fontSize;
  final VoidCallback? onTap;
  final double? width;
  final double? height;
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
          height: height ?? 40.r,
          width: width,
          alignment: Alignment.center,
          decoration: BoxDecoration(
            color: Colors.white,
            border: Border.all(color: color, width: 1),
            borderRadius: BorderRadius.circular(5.r),
          ),
          child: Text(
            title,
            style: pfMediumStyle(color: color, fontSize: fontSize),
          )),
    );
  }
}

class BgColorButton extends StatelessWidget {
  const BgColorButton({
    Key? key,
    required this.title,
    required this.color,
    this.width,
    this.height,
    this.fontSize = 15,
    this.onTap,
  }) : super(key: key);
  final String title;
  final Color color;
  final double fontSize;
  final VoidCallback? onTap;
  final double? width;
  final double? height;
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
          height: height ?? 40.r,
          width: width,
          alignment: Alignment.center,
          decoration: BoxDecoration(
            color: color,
            borderRadius: BorderRadius.circular(5.r),
          ),
          child: Text(
            title,
            style: pfMediumStyle(color: Colors.white, fontSize: fontSize),
          )),
    );
  }
}
